define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'card/entitylog/index' + location.search,
                    add_url: 'card/entitylog/add',
                    edit_url: 'card/entitylog/edit',
                    del_url: 'card/entitylog/del',
                    multi_url: 'card/entitylog/multi',
                    import_url: 'card/entitylog/import',
                    table: 'card_entitylog',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                sortOrder:'asc',
                /*fixedColumns: true,
                fixedRightNumber: 1,*/
                visible: false,
                showToggle: false,
                showColumns: false,
                search:false,
                showExport: false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                       /* {field: 'card_entity_site_id', title: __('Card_entity_site_id')},
                        {field: 'card_entity_id', title: __('Card_entity_id')},
                        {field: 'card_dealer_id', title: __('Card_dealer_id')},*/
                        {field: 'transfer_time', title: __('Transfer_time'), operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'transfer_data', title: __('Transfer_data'), searchList: {"0":__('Transfer_data 0'),"1":__('Transfer_data 1'),"2":__('Transfer_data 2'),"3":__('Transfer_data 3')}, formatter: Table.api.formatter.normal},
                        {field: 'dealer.name', title: __('Card_dealer_id'), operate: 'LIKE'},
                        {field: 'exchange_number', title: __('Exchange_number'), operate:'LIKE'},
                        {field: 'code', title: __('Code'), operate: 'LIKE'},
                        //{field: 'user_id', title: __('User_id')},
                        {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
                        {field: 'exchange_time', title: __('Exchange_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'exchange_start_time', title: __('Exchange_start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'exchange_end_time', title: __('Exchange_end_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'site.kabaw_name', title: __('Site.kabaw_name'), operate: 'LIKE'},
                        {field: 'site.kabaw_illustrate', title: __('Site.kabaw_illustrate'), operate: false},
                        {field: 'site.kabaw_fate', title: __('Site.kabaw_fate'), operate: false},
                        /*{field: 'site.kabaw_all_cost', title: __('Site.kabaw_all_cost'), operate: false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}*/
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
